/**
 * 函数类型 ——1.为函数定义类型
 */
function add(x:number,y:number):number {
  return x+y;
}
let myAdd = function(x: number, y: number): number { return x + y; };
/**
 * 函数类型 ——2.完整的函数类型
 */
let myAddTo1:(x:number,y:number)=>number = function(x:number,y:number):number {
  return x+y
}
/**
 * 可选参数和默认参数
 */
function buildName(firstName:string,lastName?:string){
  if(lastName){
    return firstName + " " +lastName;
  }
  return firstName
}
let result1 = buildName("Bob");
// let result2 = buildName("Bob","Adams","Sr"); //应有 1-2 个参数，但获得 3 个。
let result3 = buildName("Bob","Adams");

function buildNameTo1(firstName:string,lastName = "Jack"){
  return firstName + " " +lastName;
}

let resultTo1 = buildNameTo1("Bob");
let resultTo2 = buildNameTo1("Bob",undefined);
// let resultTo3 = buildNameTo1("BOb","Adams","SR.")  //应有 1-2 个参数，但获得 3 个。
let resultTo4 = buildNameTo1("Bob","Adams");

/**
 * 剩余参数
 */
function buildNameTo2(firstName:string, ...restofName:string[]){
  return firstName + " " +restofName.join("");
}
let employeeName = buildNameTo2("Joseph","Samuel","Lucas","MackInzie")

type xd = number | string | void | null | undefined | object
function buildNameTo3(firstName:string, ...props:xd[]){
  console.log(props[0]);
}
let jian = (x:number,y:number):number => {
  return x-y
}
let employeeNameTo1 = buildNameTo3("Dsa",jian,"Ds",2) 

/**
 * this ?????????
 */